'''
Created on 19.7.2011

@author: gilead
'''
from pyreddwarf.pyreddwarf import BytesArray
from protocol import *

class Messages:
    '''
    classdocs
    '''
    @staticmethod
    def CreateMovementOrderPkt(guid, x, y):
        buf = BytesArray('c')
        buf.append(chr(ORDER_MOVE_SHIP))
        buf.writeInt(guid)
        buf.writeDouble(x)
        buf.writeDouble(y)
        return buf
    '''
    @staticmethod
    def createUserIDRequestPkt():
        buf = BytesArray('c')
        buf.append(chr(REQUEST_ID))
    '''
        
    @staticmethod
    def readUserIDPkt(buf):
        id = buf.readInt()
        return id
    
    @staticmethod
    def ReadShipCreationPkt(buf):
        guid = buf.readInt()
        typeid = buf.readInt()
        #x = buf.readDouble()
        x = buf.readDouble()
        y = buf.readDouble()
        ownerid = buf.readInt()
        return guid,typeid,x,y,ownerid
    
    @staticmethod
    def ReadShipMovePkt(buf):
        guid = buf.readInt()
        x = buf.readDouble()
        y = buf.readDouble()
        vel = buf.readDouble()
        heading = buf.readDouble()
        return guid,x,y,vel,heading

    @staticmethod
    def readTurretFirePkt(buf):
        shooterGuid = buf.readInt()
        shooterTurretID = buf.readInt()
        targetGuid = buf.readInt()
        offsetlength = buf.readDouble()
        offsetwidth = buf.readDouble()
        return shooterGuid, shooterTurretID, targetGuid, offsetlength, offsetwidth

        